home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / comm / bbs / wwbbs31_source.lha / WWBBS / RxSrc / filebase_sysop.c < prev    next >
C/C++ Source or Header  |  1995-03-30  |  20KB  |  593 lines

  1. #include <exec/types.h>
  2. #include <exec/exec.h>
  3. #include <dos/dos.h>
  4. #include <dos/dosextens.h>
  5. #include <dos/exall.h>
  6. #include <libraries/asl.h>
  7. #include <libraries/wwbbs.h>
  8. #include <ctype.h>
  9. #include <math.h>
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <string.h>
  13.  
  14. #include <proto/asl.h>
  15. #include <proto/dos.h>
  16. #include <proto/exec.h>
  17. #include <proto/rexxsyslib.h>
  18. #include <proto/wwbbs.h>
  19.  
  20. #include "rx.h"
  21.  
  22. #include "filebase.h"
  23.  
  24. int move_file(char *,char *);
  25. void GetFileDescriptionsFromCommentField(BYTE *);
  26.  
  27. void UploadFromDisk(BYTE *id)
  28.     {
  29.         BOOL local=FALSE;
  30.         GetStatusTags(STTAG_Name,id,STTAG_Local,&local,TAG_END);
  31.         if(strlen(file_area))
  32.             {
  33.                 ULONG dsr=0,dfs=0;
  34.                 BYTE directory[256];
  35.                 BOOL readonly=FALSE;
  36.                 if(GetConfigTags(CFGTAG_Path,file_path,CFGTAG_Name,file_area,FBTAG_Directory,directory,FBTAG_DiskSpaceRequired,&dsr,FBTAG_ReadOnly,&readonly,TAG_END))
  37.                     {
  38.                         if(!readonly)
  39.                             {
  40.                                 {
  41.                                     BPTR lock;
  42.                                     if(lock=Lock(directory,SHARED_LOCK))
  43.                                         {
  44.                                             struct InfoData id;
  45.                                             if(Info(lock,&id))
  46.                                                 dfs=((id.id_NumBlocks-id.id_NumBlocksUsed)*id.id_BytesPerBlock)/1024;
  47.                                             UnLock(lock);
  48.                                         }
  49.                                 }
  50.                                 if(!dsr || dfs>=dsr)
  51.                                     {
  52.                                         FILE *fp;
  53.                                         BYTE file[64];
  54.                                         BOOL ok=FALSE;
  55.                                         sprintf(file,"T:wwbbs_filelog.%s",id);
  56.                                         if(fp=fopen(file,"w"))
  57.                                             {
  58.                                                 if(local)
  59.                                                     {
  60.                                                         struct FileRequester *fr;
  61.                                                         BYTE pubscreen_buff[64];
  62.                                                         sprintf(pubscreen_buff,"WWBBS Console.%s",id);
  63.                                                         if(fr=(struct FileRequester *) AllocAslRequestTags(ASL_FileRequest,ASLFR_PubScreenName,pubscreen_buff,ASLFR_TitleText,"Select File(s) for Upload",ASLFR_InitialDrawer,directory,ASLFR_InitialPattern,"~(#?.info)",ASLFR_DoMultiSelect,TRUE,ASLFR_DoPatterns,TRUE,TAG_END))
  64.                                                             {
  65.                                                                 if(AslRequestTags(fr,TAG_END))
  66.                                                                     {
  67.                                                                         if(fr->fr_NumArgs)
  68.                                                                             {
  69.                                                                                 struct WBArg *frargs;
  70.                                                                                 int i;
  71.                                                                                 frargs=fr->fr_ArgList;
  72.                                                                                 for(i=0;i<fr->fr_NumArgs;i++)
  73.                                                                                     {
  74.                                                                                         char src[256],dest[256];
  75.                                                                                         strcpy(src,fr->fr_Drawer);
  76.                                                                                         AddPart(src,frargs[i].wa_Name,255);
  77.                                                                                         strcpy(dest,directory);
  78.                                                                                         AddPart(dest,frargs[i].wa_Name,255);
  79.                                                                                         if(move_file(src,dest))
  80.                                                                                             {
  81.                                                                                                 BPTR fh;
  82.                                                                                                 if(fh=Open(dest,MODE_OLDFILE))
  83.                                                                                                     {
  84.                                                                                                         __aligned struct FileInfoBlock fib;
  85.                                                                                                         if(ExamineFH(fh,&fib))
  86.                                                                                                             {
  87.                                                                                                                 fprintf(fp,"R %ld 0 bps 0 cps 0 errors 0 0 %s 0\n",fib.fib_Size,dest);
  88.                                                                                                                 ok=TRUE;
  89.                                                                                                             }
  90.                                                                                                         Close(fh);
  91.                                                                                                     }
  92.                                                                                                 else
  93.                                                                                                     move_file(dest,src);
  94.                                                                                             }
  95.                                                                                     }
  96.                                                                             }
  97.                                                                         else
  98.                                                                             {
  99.                                                                                 if(strlen(fr->fr_File))
  100.                                                                                     {
  101.                                                                                         char src[256],dest[256];
  102.                                                                                         strcpy(src,fr->fr_Drawer);
  103.                                                                                         AddPart(src,fr->fr_File,255);
  104.                                                                                         strcpy(dest,directory);
  105.                                                                                         AddPart(dest,fr->fr_File,255);
  106.                                                                                         if(move_file(src,dest))
  107.                                                                                             {
  108.                                                                                                 BPTR fh;
  109.                                                                                                 if(fh=Open(dest,MODE_OLDFILE))
  110.                                                                                                     {
  111.                                                                                                         __aligned struct FileInfoBlock fib;
  112.                                                                                                         if(ExamineFH(fh,&fib))
  113.                                                                                                             {
  114.                                                                                                                 fprintf(fp,"R %ld 0 bps 0 cps 0 errors 0 0 %s 0\n",fib.fib_Size,dest);
  115.                                                                                                                 ok=TRUE;
  116.                                                                                                             }
  117.                                                                                                         Close(fh);
  118.                                                                                                     }
  119.                                                                                                 else
  120.                                                                                                     move_file(dest,src);
  121.                                                                                             }
  122.                                                                                     }
  123.                                                                             }
  124.                                                                     }
  125.                                                                 FreeAslRequest(fr);
  126.                                                             }
  127.                                                     }
  128.                                                 else
  129.                                                     {
  130.                                                         char patternbuff[128],pattern[256],path[256],file[256];
  131.                                                         printf("~p\nEnter an AmigaDOS style file pattern to upload from disk.\nFile names are also acceptable.\n: ");
  132.                                                         if(GetLine(patternbuff,127,NULL))
  133.                                                             {
  134.                                                                 strcpy(path,patternbuff);
  135.                                                                 {
  136.                                                                     char *p;
  137.                                                                     p=PathPart(path);
  138.                                                                     *p=NULL;
  139.                                                                 }
  140.                                                                 strcpy(file,FilePart(patternbuff));
  141.                                                                 ParsePatternNoCase(file,pattern,255);
  142.                                                                 {
  143.                                                                     BPTR lock;
  144.                                                                     if(lock=Lock(path,SHARED_LOCK))
  145.                                                                         {
  146.                                                                             struct ExAllControl *eac;
  147.                                                                             struct ExAllData *ead,*eadata;
  148.                                                                             int more;
  149.                                                                             if(eac=AllocDosObject(DOS_EXALLCONTROL,NULL))
  150.                                                                                 {
  151.                                                                                     eac->eac_LastKey=0;
  152.                                                                                     if(eadata=AllocVec(sizeof(struct ExAllData)*16,MEMF_CLEAR))
  153.                                                                                         {
  154.                                                                                             do
  155.                                                                                                 {
  156.                                                                                                     more=ExAll(lock,eadata,sizeof(struct ExAllData)*16,ED_SIZE,eac);
  157.                                                                                                     if((!more) && (IoErr()!=ERROR_NO_MORE_ENTRIES))
  158.                                                                                                         break;
  159.                                                                                                     if(eac->eac_Entries==0)
  160.                                                                                                         continue;
  161.                                                                                                     {
  162.                                                                                                         ead=eadata;
  163.                                                                                                         do
  164.                                                                                                             {
  165.                                                                                                                 {
  166.                                                                                                                     if(MatchPatternNoCase(pattern,ead->ed_Name))
  167.                                                                                                                         {
  168.                                                                                                                             char src[256],dest[256];
  169.                                                                                                                             strcpy(src,path);
  170.                                                                                                                             AddPart(src,ead->ed_Name,255);
  171.                                                                                                                             strcpy(dest,directory);
  172.                                                                                                                             AddPart(dest,ead->ed_Name,255);
  173.                                                                                                                             if(move_file(src,dest))
  174.                                                                                                                                 fprintf(fp,"R %ld 0 bps 0 cps 0 errors 0 0 %s 0\n",ead->ed_Size,dest);
  175.                                                                                                                         }
  176.                                                                                                                 }
  177.                                                                                                                 ead=ead->ed_Next;
  178.                                                                                                             } while(ead);
  179.                                                                                                     }
  180.                                                                                                 } while(more);
  181.                                                                                             FreeVec(eadata);
  182.                                                                                         }
  183.                                                                                     FreeDosObject(DOS_EXALLCONTROL,eac);
  184.                                                                                 }
  185.                                                                             UnLock(lock);
  186.                                                                         }
  187.                                                                 }
  188.                                                                 ok=TRUE;
  189.                                                             }
  190.                                                     }
  191.                                                 fclose(fp);
  192.                                                 if(ok)
  193.                                                     {
  194.                                                         ProcessLogFile(id);
  195.                                                         GetFileDescriptionsFromCommentField(id);
  196.                                                         GetFileDescriptions(id);
  197.                                                     }
  198.                                                 DeleteFile(file);
  199.                                             }
  200.                                     }
  201.                                 else
  202.                                     printf("~s\nThere is not enough disk space for uploads.\n");
  203.                             }
  204.                         else
  205.                             printf("~s\nThis file area is read only.\n");
  206.                     }
  207.             }
  208.         else
  209.             printf("~s\nPlease enter a file area first.\n");
  210.     }
  211.  
  212. void KillFile(BYTE *id)
  213.     {
  214.         if(strlen(file_area))
  215.             {
  216.                 if(file_current)
  217.                     {
  218.                         BYTE file[256];
  219.                         strcpy(file,"");
  220.                         if(GetConfigTags(CFGTAG_Path,file_path,CFGTAG_Name,file_area,FBTAG_Directory,file,TAG_END))
  221.                             {
  222.                                 APTR group;
  223.                                 if(group=OpenFileGroup(file_path,file_area,EXCLUSIVE_LOCK))
  224.                                     {
  225.                                         BYTE *name=NULL,*uploader=NULL;
  226.                                         ULONG size=0;
  227.                                         if(GetFileTags(group,FILTAG_ID,file_current,FILTAG_Name,&name,FILTAG_Size,&size,FILTAG_Uploader,&uploader,TAG_END))
  228.                                             {
  229.                                                 AddPart(file,name,255);
  230.                                                 printf("~p\nKill `%s' (Y,[N])? ",name);
  231.                                                 if(Ask(NULL,FALSE))
  232.                                                     {
  233.                                                         printf("~p\nRemove credits from `%s' ([Y],N)? ",uploader);
  234.                                                         if(Ask(NULL,TRUE))
  235.                                                             {
  236.                                                                 UBYTE ratiobyte=0,ratiofile=0;
  237.                                                                 ULONG filesupld=0,filescredits=0,kilosupld,kiloscredits=0;
  238.                                                                 if(GetUserTags(USRTAG_Name,uploader,USRTAG_RatioByte,&ratiobyte,USRTAG_RatioFile,&ratiofile,USRTAG_FilesUploaded,&filesupld,USRTAG_FilesCredits,&filescredits,USRTAG_KilosUploaded,&kilosupld,USRTAG_KilosCredits,&kiloscredits,TAG_END))
  239.                                                                     {
  240.                                                                         if(filesupld)
  241.                                                                             filesupld--;
  242.                                                                         if(ratiofile && filescredits)
  243.                                                                             filescredits--;
  244.                                                                         kilosupld=(kilosupld>size/1024) ? kilosupld-(size/1024) : 0;
  245.                                                                         if(ratiobyte)
  246.                                                                             kiloscredits=(kiloscredits>size/1024) ? kiloscredits-(size/1024) : 0;
  247.                                                                         SetUserTags(USRTAG_Name,uploader,USRTAG_FilesUploaded,filesupld,USRTAG_FilesCredits,filescredits,USRTAG_KilosUploaded,kilosupld,USRTAG_KilosCredits,kiloscredits,TAG_END);
  248.                                                                     }
  249.                                                             }
  250.                                                         printf("~p\nDelete `%s' from disk ([Y],N)? ",name);
  251.                                                         if(Ask(NULL,TRUE))
  252.                                                             DeleteFile(file);
  253.                                                         if(RemFileTags(group,FILTAG_ID,file_current,TAG_END))
  254.                                                             {
  255.                                                                 file_current=GetPreviousFile(group,file_current);
  256.                                                                 file_promptlow=GetNextFile(group,0);
  257.                                                                 file_prompthigh=GetPreviousFile(group,~0);
  258.                                                                 if(file_current>file_prompthigh)
  259.                                                                     file_current=file_prompthigh;
  260.                                                                 if(file_high>file_prompthigh)
  261.                                                                     file_high=file_prompthigh;
  262.                                                                 {
  263.                                                                     BYTE file_group[41];
  264.                                                                     GetConfigTags(CFGTAG_Path,file_path,CFGTAG_Name,file_area,FBTAG_Group,file_group,TAG_END);
  265.                                                                     SetFileGlobalHigh(file_global,file_group,file_high);
  266.                                                                 }
  267.                                                             }
  268.                                                         else
  269.                                                             printf("~s\nUnable to kill `%s'.\n",name);
  270.                                                     }
  271.                                             }
  272.                                         CloseFileGroup(group);
  273.                                     }
  274.                             }
  275.                     }
  276.                 else
  277.                     printf("~s\nCurrent file does not exist.\n");
  278.             }
  279.         else
  280.             printf("~s\nPlease enter a file area first.\n");
  281.     }
  282.  
  283. void MoveFile(BYTE *id)
  284.     {
  285.         if(strlen(file_area))
  286.             {
  287.                 if(file_current)
  288.                     {
  289.                         BOOL isgetfile=FALSE;
  290.                         BYTE file_path_dest[256],*file_area_dest=NULL;
  291.                         BYTE file_src[256],file_dest[256];
  292.                         BYTE name[33],uploader[33],*description=NULL;
  293.                         ULONG size=0;
  294.                         struct DateStamp date,lastdownloaddate;
  295.                         UWORD downloads=0;
  296.                         strcpy(file_path_dest,"FileBases/");
  297.                         strcpy(file_src,"");
  298.                         strcpy(file_dest,"");
  299.                         {
  300.                             APTR group_src;
  301.                             if(group_src=OpenFileGroup(file_path,file_area,EXCLUSIVE_LOCK))
  302.                                 {
  303.                                     if(GetFileGroupDirectory(group_src,file_src,255))
  304.                                         {
  305.                                             BYTE *name_buff=NULL,*uploader_buff=NULL,*description_buff=NULL;
  306.                                             struct DateStamp *date_buff=NULL,*lastdownloaddate_buff=NULL;
  307.                                             if(GetFileTags(group_src,FILTAG_ID,file_current,FILTAG_Name,&name_buff,FILTAG_Uploader,&uploader_buff,FILTAG_Size,&size,FILTAG_Date,&date_buff,FILTAG_Downloads,&downloads,FILTAG_LastDownloadDate,&lastdownloaddate_buff,FILTAG_Description,&description_buff,TAG_END))
  308.                                                 {
  309.                                                     strcpy(name,name_buff);
  310.                                                     strcpy(uploader,uploader_buff);
  311.                                                     date=*date_buff;
  312.                                                     lastdownloaddate=*lastdownloaddate_buff;
  313.                                                     if(description_buff && strlen(description_buff))
  314.                                                         {
  315.                                                             if(description=AllocVec(sizeof(BYTE)*(strlen(description_buff)+1),MEMF_CLEAR))
  316.                                                                 strcpy(description,description_buff);
  317.                                                         }
  318.                                                     AddPart(file_src,name,255);
  319.                                                     printf("~p\nEnter the full path of the file base to move `%s' to.\n: ",name);
  320.                                                     if(GetLine(&file_path_dest[strlen(file_path_dest)],255-strlen(file_path_dest),NULL))
  321.                                                         {
  322.                                                             if(file_area_dest=FilePart(file_path_dest))
  323.                                                                 {
  324.                                                                     {
  325.                                                                         char *p;
  326.                                                                         p=file_area_dest;
  327.                                                                         p--;
  328.                                                                         *p=NULL;
  329.                                                                     }
  330.                                                                     if(!(!stricmp(file_path_dest,file_path) && !stricmp(file_area_dest,file_area)))
  331.                                                                         {
  332.                                                                             if(RemFileTags(group_src,FILTAG_ID,file_current,TAG_END))
  333.                                                                                 {
  334.                                                                                     file_current=GetPreviousFile(group_src,file_current);
  335.                                                                                     file_promptlow=GetNextFile(group_src,0);
  336.                                                                                     file_prompthigh=GetPreviousFile(group_src,~0);
  337.                                                                                     if(file_current>file_prompthigh)
  338.                                                                                         file_current=file_prompthigh;
  339.                                                                                     if(file_high>file_prompthigh)
  340.                                                                                         file_high=file_prompthigh;
  341.                                                                                     {
  342.                                                                                         BYTE file_group[41];
  343.                                                                                         strcpy(file_group,"");
  344.                                                                                         GetConfigTags(CFGTAG_Path,file_path,CFGTAG_Name,file_area,FBTAG_Group,file_group,TAG_END);
  345.                                                                                         SetFileGlobalHigh(file_global,file_group,file_high);
  346.                                                                                     }
  347.                                                                                     isgetfile=TRUE;
  348.                                                                                 }
  349.                                                                             else
  350.                                                                                 printf("~s\nUnable to remove source file.\n");
  351.                                                                         }
  352.                                                                     else
  353.                                                                         printf("~s\n`%s' is already in `%s/%s'.\n",name,file_path_dest,file_area_dest);
  354.                                                                 }
  355.                                                         }
  356.                                                 }
  357.                                             else
  358.                                                 printf("~s\nUnable to get file.\n");
  359.                                         }
  360.                                     else
  361.                                         printf("~s\nUnable to get directory.\n");
  362.                                     CloseFileGroup(group_src);
  363.                                 }
  364.                             else
  365.                                 printf("~s\nUnable to open `%s/%s'.\n",file_path,file_area);
  366.                         }
  367.                         if(isgetfile)
  368.                             {
  369.                                 APTR group_dest;
  370.                                 if(group_dest=OpenFileGroup(file_path_dest,file_area_dest,EXCLUSIVE_LOCK))
  371.                                     {
  372.                                         if(GetFileGroupDirectory(group_dest,file_dest,255))
  373.                                             {
  374.                                                 AddPart(file_dest,name,255);
  375.                                                 if(move_file(file_src,file_dest))
  376.                                                     {
  377.                                                         ULONG dest_id;
  378.                                                         if(dest_id=AddFileTags(group_dest,FILTAG_DontSave,TRUE,TAG_END))
  379.                                                             {
  380.                                                                 if(!SetFileTags(group_dest,FILTAG_ID,dest_id,FILTAG_Name,name,FILTAG_Uploader,uploader,FILTAG_Size,size,FILTAG_Date,&date,FILTAG_Downloads,downloads,FILTAG_LastDownloadDate,&lastdownloaddate,FILTAG_Description,description,TAG_END))
  381.                                                                     {
  382.                                                                         RemFileTags(group_dest,FILTAG_ID,dest_id,TAG_END);
  383.                                                                         move_file(file_dest,file_src);
  384.                                                                         printf("~s\nUnable to set destination file attributes.\n");
  385.                                                                     }
  386.                                                             }
  387.                                                         else
  388.                                                             {
  389.                                                                 move_file(file_dest,file_src);
  390.                                                                 printf("~s\nUnable to add file to destination group.\n");
  391.                                                             }
  392.                                                     }
  393.                                                 else
  394.                                                     printf("~s\nUnable to move file.\n");
  395.                                             }
  396.                                         else
  397.                                             printf("~s\nUnable to get directory.\n");
  398.                                         CloseFileGroup(group_dest);
  399.                                     }
  400.                                 else
  401.                                     printf("~s\nUnable to open `%s/%s'.\n",file_path_dest,file_area_dest);
  402.                             }
  403.                         if(description)
  404.                             FreeVec(description);
  405.                     }
  406.                 else
  407.                     printf("~s\nCurrent file does not exist.\n");
  408.             }
  409.         else
  410.             printf("~s\nPlease enter a file area first.\n");
  411.     }
  412.  
  413. int move_file(char *src,char *dest)
  414.     {
  415.         int exists=FALSE,samelock=FALSE,ret=FALSE;
  416.         {
  417.             BPTR fh;
  418.             if(fh=Open(dest,MODE_OLDFILE))
  419.                 {
  420.                     exists=TRUE;
  421.                     Close(fh);
  422.                 }
  423.         }
  424.         if(!exists)
  425.             {
  426.                 if(Rename(src,dest))
  427.                     ret=TRUE;
  428.                 else
  429.                     {
  430.                         BPTR src_fh,dest_fh;
  431.                         int ok=FALSE;
  432.                         if(src_fh=Open(src,MODE_OLDFILE))
  433.                             {
  434.                                 if(dest_fh=Open(dest,MODE_NEWFILE))
  435.                                     {
  436.                                         char *p;
  437.                                         if(p=AllocMem(sizeof(char)*32768,MEMF_CLEAR))
  438.                                             {
  439.                                                 LONG count;
  440.                                                 while((count=Read(src_fh,p,sizeof(char)*32768))>0)
  441.                                                     Write(dest_fh,p,count);
  442.                                                 ok=TRUE;
  443.                                                 FreeMem(p,sizeof(char)*32768);
  444.                                             }
  445.                                         Close(dest_fh);
  446.                                     }
  447.                                 Close(src_fh);
  448.                             }
  449.                         if(ok)
  450.                             {
  451.                                 DeleteFile(src);
  452.                                 ret=TRUE;
  453.                             }
  454.                     }
  455.                 if(!ret)
  456.                     printf("~s\nUnable to move `%s'.\n",src);
  457.             }
  458.         else
  459.             {
  460.                 {
  461.                     BPTR src_lock,dest_lock;
  462.                     if(src_lock=Lock(src,SHARED_LOCK))
  463.                         {
  464.                             if(dest_lock=Lock(dest,SHARED_LOCK))
  465.                                 {
  466.                                     if(SameLock(src_lock,dest_lock)==LOCK_SAME)
  467.                                         samelock=TRUE;
  468.                                     UnLock(dest_lock);
  469.                                 }
  470.                             UnLock(src_lock);
  471.                         }
  472.                 }
  473.                 if(samelock)
  474.                     ret=TRUE;
  475.                 else
  476.                     printf("~s\n`%s' already exists.\n",dest);
  477.             }
  478.         return(ret);
  479.     }
  480.  
  481. void EditFileDescription(BYTE *id)
  482.     {
  483.         if(strlen(file_area))
  484.             {
  485.                 if(file_current)
  486.                     {
  487.                         APTR group;
  488.                         if(group=OpenFileGroup(file_path,file_area,EXCLUSIVE_LOCK))
  489.                             {
  490.                                 BYTE *name=NULL,*description=NULL;
  491.                                 if(GetFileTags(group,FILTAG_ID,file_current,FILTAG_Name,&name,FILTAG_Description,&description,TAG_END))
  492.                                     {
  493.                                         BYTE file[128];
  494.                                         sprintf(file,"T:%s.%s",name,id);
  495.                                         if(description)
  496.                                             {
  497.                                                 FILE *fp;
  498.                                                 if(fp=fopen(file,"w"))
  499.                                                     {
  500.                                                         fputs(description,fp);
  501.                                                         fclose(fp);
  502.                                                     }
  503.                                             }
  504.                                         printf("~s\nPlease enter a description for `%s'.\n",name);
  505.                                         if(RunEditor(file))
  506.                                             {
  507.                                                 BYTE *buff=NULL;
  508.                                                 {
  509.                                                     BPTR fh;
  510.                                                     if(fh=Open(file,MODE_OLDFILE))
  511.                                                         {
  512.                                                             __aligned struct FileInfoBlock fib;
  513.                                                             if(ExamineFH(fh,&fib))
  514.                                                                 {
  515.                                                                     if(buff=AllocVec(fib.fib_Size+1,MEMF_CLEAR))
  516.                                                                         {
  517.                                                                             if(FRead(fh,buff,sizeof(BYTE),fib.fib_Size)==fib.fib_Size)
  518.                                                                                 SetFileTags(group,FILTAG_ID,file_current,FILTAG_Description,buff,TAG_END);
  519.                                                                             FreeVec(buff);
  520.                                                                         }
  521.                                                                 }
  522.                                                             Close(fh);
  523.                                                         }
  524.                                                 }
  525.                                             }
  526.                                         DeleteFile(file);
  527.                                     }
  528.                                 CloseFileGroup(group);
  529.                             }
  530.                     }
  531.                 else
  532.                     printf("~s\nCurrent file does not exist.\n");
  533.             }
  534.         else
  535.             printf("~s\nPlease enter a file area first.\n");
  536.     }
  537.  
  538. void GetFileDescriptionsFromCommentField(BYTE *id)
  539.     {
  540.         BYTE user[33];
  541.         strcpy(user,"");
  542.         GetStatusTags(STTAG_Name,id,STTAG_UserName,user,TAG_END);
  543.         if(strlen(user))
  544.             {
  545.                 APTR group;
  546.                 if(group=OpenFileGroup(file_path,file_area,EXCLUSIVE_LOCK))
  547.                     {
  548.                         ULONG next=0;
  549.                         BYTE *name=NULL;
  550.                         BYTE *uploader=NULL;
  551.                         BYTE *description=NULL;
  552.                         while(next=GetNextFile(group,next))
  553.                             {
  554.                                 if(GetFileTags(group,FILTAG_ID,next,FILTAG_Name,&name,FILTAG_Uploader,&uploader,FILTAG_Description,&description,TAG_END))
  555.                                     {
  556.                                         if(!description && !stricmp(uploader,user))
  557.                                             {
  558.                                                 BYTE filename[256];
  559.                                                 strcpy(filename,"");
  560.                                                 if(GetFileGroupDirectory(group,filename,255))
  561.                                                     {
  562.                                                         if(AddPart(filename,name,255))
  563.                                                             {
  564.                                                                 BPTR fh;
  565.                                                                 if(fh=Open(filename,MODE_OLDFILE))
  566.                                                                     {
  567.                                                                         __aligned struct FileInfoBlock fib;
  568.                                                                         if(ExamineFH(fh,&fib))
  569.                                                                             {
  570.                                                                                 if(strlen(fib.fib_Comment))
  571.                                                                                     {
  572.                                                                                         printf("~o\n`%s' has the following file comment:\n%s\n",name,fib.fib_Comment);
  573.                                                                                         if(Ask("Would you like to use it",TRUE))
  574.                                                                                             {
  575.                                                                                                 char description[81];
  576.                                                                                                 sprintf(description,"%s\n",fib.fib_Comment);
  577.                                                                                                 SetFileTags(group,FILTAG_ID,next,FILTAG_Description,description,FILTAG_DontSave,TRUE,TAG_END);
  578.                                                                                             }
  579.                                                                                     }
  580.                                                                             }
  581.                                                                         Close(fh);
  582.                                                                     }
  583.                                                             }
  584.                                                     }
  585.                                             }
  586.                                     }
  587.                             }
  588.                         SetFileTags(group,FILTAG_ForceSave,TRUE,TAG_END);
  589.                         CloseFileGroup(group);
  590.                     }
  591.             }
  592.     }
  593.